package xixirupan.tmgp.tencent.com.vmeim.ui.beautycircle.view;


import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import xixirupan.tmgp.tencent.com.vmeim.R;
import xixirupan.tmgp.tencent.com.vmeim.ui.beautycircle.presenter.CirclePagerAdapter;


/**
 * Created by lenovo on 2016/10/18.
 */

public class BeautyCircleFragment extends Fragment implements IViewCircle {
    @BindView(R.id.circle_tabLayout)
    TabLayout circleTabLayout;
    @BindView(R.id.circle_search)
    ImageView circleSearch;
    @BindView(R.id.cicler_viewpager)
    ViewPager ciclerViewpager;
    private Unbinder bind;
    private Context context;
    private  String[] tabCircle;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context =context;
    }





    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_quan_layout, container, false);
        bind = ButterKnife.bind(this, view);
        setTabLayout();
        initViewPager();
        return view;

    }

    @OnClick(R.id.circle_search)
    public void onClick() {
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        bind.unbind();
    }

    @Override
    public void setTabLayout() {
         tabCircle = getResources().getStringArray(R.array.circleTab);
        for (int i = 0; i < tabCircle.length; i++) {
            circleTabLayout.addTab(circleTabLayout.newTab().setText(tabCircle[i]));

        }

    }

    @Override
    public void initViewPager() {
        List <Fragment> lists =new ArrayList<>();
        lists.add(new EssenseFragment());
        lists.add(new CareFragment());
        CirclePagerAdapter adapter =new CirclePagerAdapter(getChildFragmentManager(), lists,tabCircle);
        ciclerViewpager.setAdapter(adapter);
        circleTabLayout.setupWithViewPager(ciclerViewpager);
    }
}
